﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using BASE;


public partial class thoikhoabieu : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (Utils.getStringSession("masv") == "")
        {
            Response.Redirect("/");

        }
        dr_th.SelectedIndexChanged += new EventHandler(dr_th_SelectedIndexChanged);
        if (!IsPostBack)
        {
            int k = getTuanHienTai();
            txt_lop.Text = Utils.getStringSession("Malop");
            binTuan();
            ListItem lstitem = new ListItem();
            lstitem = dr_th.Items.FindByValue(k.ToString());
            if (lstitem != null)
            {
                lstitem.Selected = true;
            }

            binlichhoc(k, txt_lop.Text);
        }
        Session["menu"] = Constants.THOIKHOABIEN;
    }

    void dr_th_SelectedIndexChanged(object sender, EventArgs e)
    {
       // binlichhoc(int.Parse(dr_th.SelectedValue), txt_lop.Text);
    }
    int getTuanHienTai()
    {
        busTuan busT = new busTuan();
        return busT.getTuanHienTai();
    }
    void binTuan()
    {
        busTuan busT = new busTuan();
        dr_th.DataSource = busT.getAllTuan();
        dr_th.DataTextField = "Ten";
        dr_th.DataValueField = "Tuan";
        dr_th.DataBind();
    }
    void binlichhoc(int tuan, string lop)
    {
        busThoiKhoaBieu busTK = new busThoiKhoaBieu();
        List<entThoiKhoaBieu> lst = new List<entThoiKhoaBieu>();
        lst = busTK.getByTuan(tuan, lop);
        gr_tkb.DataSource = lst;
        gr_tkb.DataBind();
    }
    protected void btn_ok_Click(object sender, EventArgs e)
    {
        binlichhoc(int.Parse(dr_th.SelectedValue), txt_lop.Text);
    }
}